package main

import (
	"fmt"
	"os"
	"path/filepath"
	"strings"
)

// 目录结构
var dirStructure = map[string][]string{
	"map":      {"guide"},
	"calendar": {"info"},
	"weather":  {"info"},
	"forum":    {"rules"},
	"takeout":  {"guide"},
	"helper":   {"guide"},
	"official": {"info"},
	"schedule": {"guide"},
	"grades":   {"guide"},

	"freshman": {"items", "preparation", "commute", "tuition", "security"},
	"study":    {"transfer", "certificate", "library", "english"},
	"life":     {"dorm", "express", "bath", "internet", "guide", "transport", "canteen", "market"},
	"about":    {"school", "overview", "aid", "us"},
	"colleges": {"art", "teacher", "management", "science", "literature", "engineering", "preschool", "language", "sports"},
	"food":     {"guide"},
	"help":     {"center"},
	"privacy":  {"policy"},
	"contact":  {"info"},
	"user":     {"profile", "settings"},
}

// 模板内容
func getTemplateContent(category, item string) string {
	title := strings.Title(item) + "指南"
	if category == "about" {
		if item == "school" {
			title = "关于学校"
		} else if item == "overview" {
			title = "学校概况"
		} else if item == "aid" {
			title = "资助信息"
		} else if item == "us" {
			title = "关于我们"
		}
	} else if category == "colleges" {
		title = strings.Title(item) + "学院介绍"
	} else if category == "freshman" {
		if item == "items" {
			title = "新生需带物品"
		} else if item == "preparation" {
			title = "入学准备"
		} else if item == "commute" {
			title = "走读指南"
		} else if item == "tuition" {
			title = "学费缴纳"
		} else if item == "security" {
			title = "防盗防骗"
		}
	} else if category == "study" {
		if item == "transfer" {
			title = "转专业指南"
		} else if item == "certificate" {
			title = "教师资格证"
		} else if item == "library" {
			title = "图书馆指南"
		} else if item == "english" {
			title = "英语A级考试"
		}
	} else if category == "life" {
		if item == "dorm" {
			title = "寝室指南"
		} else if item == "express" {
			title = "快递指南"
		} else if item == "bath" {
			title = "洗浴指南"
		} else if item == "internet" {
			title = "校园网指南"
		} else if item == "guide" {
			title = "生活指南"
		} else if item == "transport" {
			title = "交通出行"
		} else if item == "canteen" {
			title = "食堂指南"
		} else if item == "market" {
			title = "校园超市"
		}
	} else if category == "calendar" && item == "info" {
		title = "校历信息"
	} else if category == "weather" && item == "info" {
		title = "天气信息"
	} else if category == "forum" && item == "rules" {
		title = "论坛规则"
	} else if category == "help" && item == "center" {
		title = "帮助中心"
	} else if category == "privacy" && item == "policy" {
		title = "隐私政策"
	} else if category == "contact" && item == "info" {
		title = "联系信息"
	} else if category == "user" {
		if item == "profile" {
			title = "用户资料"
		} else if item == "settings" {
			title = "用户设置"
		}
	}

	return fmt.Sprintf(`# %s

## 概述

这是关于%s的详细指南，帮助南通大学的学生了解相关信息和操作流程。

## 主要内容

### 基本信息

- 这是%s的基本信息
- 包含重要的说明和注意事项
- 提供官方联系方式和参考资源

### 详细指南

1. 第一部分内容说明
2. 第二部分内容说明
3. 第三部分内容说明
4. 更多相关信息...

## 常见问题

### 问题1：这是一个常见问题？
这是对常见问题1的详细解答。

### 问题2：这是另一个常见问题？
这是对常见问题2的详细解答。

## 联系方式

如有疑问，请联系相关部门：
- 电话：0513-8501XXXX
- 邮箱：example@ntu.edu.cn
- 地点：南通大学XX楼XXX室

---

*最后更新：2025年7月11日*
`, title, title, title)
}

func main() {
	baseDir := "data/content"

	// 确保基础目录存在
	if err := os.MkdirAll(baseDir, 0755); err != nil {
		fmt.Printf("创建基础目录失败: %v\n", err)
		return
	}

	// 遍历目录结构，创建文件
	for category, items := range dirStructure {
		categoryDir := filepath.Join(baseDir, category)

		// 创建分类目录
		if err := os.MkdirAll(categoryDir, 0755); err != nil {
			fmt.Printf("创建目录失败 %s: %v\n", categoryDir, err)
			continue
		}

		// 为每个项目创建Markdown文件
		for _, item := range items {
			filePath := filepath.Join(categoryDir, item+".md")

			// 检查文件是否已存在
			if _, err := os.Stat(filePath); err == nil {
				fmt.Printf("文件已存在，跳过: %s\n", filePath)
				continue
			}

			// 创建内容
			content := getTemplateContent(category, item)

			// 写入文件
			if err := os.WriteFile(filePath, []byte(content), 0644); err != nil {
				fmt.Printf("写入文件失败 %s: %v\n", filePath, err)
				continue
			}

			fmt.Printf("创建文件成功: %s\n", filePath)
		}
	}

	fmt.Println("内容生成完成!")
}
